﻿using System;
using OpenTK;

namespace Mono.Rift.Core.Graphics
{
	public class Node
	{
		private Vector3 _pos;
		public Vector3 Pos { 
			get { return _pos; }
			set {
				_pos = value;
				MatCurrent = false;
			}
		}

		private Quaternion _rot;
		public Quaternion Rot { 
			get { return _rot; }
			set {
				_rot = value;
				MatCurrent = false;
			}
		}

		private Matrix4 _mat;
		public Matrix4 Mat { 
			get { 
				if (!MatCurrent) {
					_mat = Matrix4.CreateFromQuaternion (_rot);
					_mat = Matrix4.Mult(Matrix4.CreateTranslation (_pos), _mat);
					MatCurrent = true;
				}
				return _mat; 
			}

			set {
				_mat = value;
				MatCurrent = true;
			}
		}

		public bool MatCurrent { get; set; }

		public NodeTypes NodeType { get; set; }

		public virtual void clearRenderer()
		{
		}

		public Node ()
		{
			NodeType = NodeTypes.NonDisplay;
			_pos = Vector3.Zero;
			_rot = Quaternion.Identity;
			_mat = Mat;

		}

		public virtual void render(Matrix4 ltw, RenderDevice device)
		{
		}
	}
}

